<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<button id="btn">设置 cookie </button>
</body>
<script>
	document.getElementById( 'btn' ).onclick = function () {
		document.cookie = 'key=value; path=/';
	};
</script>
</html>